﻿@model RiderShop.Mobile.Modle.CategoryModel
@{

    int cateId = 2;
    if (!string.IsNullOrEmpty(Request.QueryString["sid"]) && Model.SubCategories != null & Model.SubCategories.Count > 0)
    {

        var cate = Model.Categories.FirstOrDefault(s => s.CategoryId == int.Parse(Request.QueryString["sid"]));
        if (cate != null)
        {
            cateId = cate.CategoryId;
        }
        else
        {

            cate = Model.SubCategories.FirstOrDefault(s => s.CategoryId == int.Parse(Request.QueryString["sid"]));
            if (cate != null)
            {
                cateId = cate.ParentCategoryId.HasValue ? cate.ParentCategoryId.Value : 2;
            }
        }
    }
}
<dl class="category-list">
    <dt>@Model.Groups[0].CategoryName</dt>
    <dd class="category-sub-bellows">

        @foreach (var category in Model.Categories)
        {
            <div class="bellows__item @(cateId == category.CategoryId ? "bellows--is-open" : "")">
                <h4 class="bellows__header"><i></i>@category.CategoryName</h4>
                <div class="bellows__content category-sub">
                    @foreach (var subcategory in Model.SubCategories.Where(s => s.ParentCategoryId == category.CategoryId))
                    {
                        <a href="/Product/ProductList?sid=@subcategory.CategoryId">@subcategory.CategoryName</a>
                    }
                </div>
            </div>
        }

    </dd>
</dl>
